<!-- php100之留言板：php100_message_add.php -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<?php
error_reporting(7);
 include("php100_message_conn.php");

 if($_POST['submit']){


  $sql="insert into message (id,user,title,content,lastdate) " .
  		"values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
  mysql_query($sql);
  echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";

 }
 include("php100_message_head.php");
?>
<SCRIPT language=javascript>
function CheckPost()
{
	if (myform.user.value=="")
	{
		alert("请填写用户名");
		myform.user.focus();
		return false;
	}
	if (myform.title.value.length<5)
	{
		alert("标题不能少于5个字符");
		myform.title.focus();
		return false;
	}
	if (myform.content.value=="")
	{
		alert("必须要填写留言内容");
		myform.content.focus();
		return false;
	}
}
</SCRIPT>

  <form action="php100_message_add.php" method="post" name="myform" onsubmit="return CheckPost();">
  <img src="http://localhost/image/first.jpg" height="239" width="1170" /><br>
  用户：<input type="text" size="10" name="user" /><br>
  标题：<input type="text" name="title" /><br/>
  内容：<textarea name="content"  cols="60" rows="9"></textarea><br/>

  <input type="submit" name="submit" value="发布留言"/>
  </form>
</head>
</html>